﻿using System;
using System.Collections.Generic;
using System.Text;
using CadStrategy2013.DxfData;
using MyIni;

namespace CadStrategy2013.CgqStyle
{
    public class ZLBsClass:Cgq2013
    {
        public ZLBsClass(string secname)
            : base(secname)
        {
        }
        public ZLBsClass(string secname, string id)
            : base(secname, id)
        {
        }
        public ZLBsClass(string secname,Dictionary<string,string> dic)
            :base(secname,dic)
        {
        }
        //public override void GetCfg()
        //{
        //    base.GetCfg();
        //    GetCfg("直流道岔表示");
        //}
        public override List<string> ReadTemplateDxf()
        {
            return ReadDxf(Path + "\\template\\直流道岔表示电压.dll");
        }
        public override string GetSaveFileName(int index)
        {
            if (ShiJiTuZhiCount == 1)
                return "\\直流道岔表示电压.dxf";
            return "\\直流道岔表示电压" + (index + 1).ToString() + ".dxf";
            //if (index == 0)
            //    return "\\直流道岔表示电压.dxf";
            //else
            //    return "\\直流道岔表示电压" + index + ".dxf";
        }
        public override DxfDataClass GetDxfData()
        {
            DxfDataClass dxfDataClass = new DxfDataClass();

            IniFile inifile = new IniFile("./\\" + StationName + "\\dc.txt");
            int sum0 = inifile.GetInt16("直流道岔", "sum", 0);
            for (int i = 0; i < sum0; i++)
            {
                DevClass devClass = new DevClass();
                string strs = inifile.GetString("直流道岔", (i + 1).ToString(), "");
                string[] s = strs.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                int n = s.Length;
                devClass.DevName = s[0] ;
                if (n <= 1)
                {
                    devClass.peiList.Add(" ");
                    devClass.peiList.Add(" ");
                    devClass.peiList.Add(" ");
                    devClass.peiList.Add(" ");
                    dxfDataClass.devList.Add(devClass);
                }
                else
                {
                    devClass.peiList.Add(s[1] + "-1");
                    devClass.peiList.Add(s[1] + "-3");
                    devClass.peiList.Add(s[1] + "-2");
                    devClass.peiList.Add(s[1] + "-3");
                    dxfDataClass.devList.Add(devClass);
                }
            }
            if (sum0 != 0)
            {
                ShiJiBanCount = (dxfDataClass.devList.Count - 1) / BanDevCount + 1;
                ShiJiTuZhiCount = (ShiJiBanCount - 1) / BanCount + 1;
            }
            else
            {
                ShiJiBanCount = 0;
                ShiJiTuZhiCount = 0;
            }

            m_dxfDataClass = dxfDataClass;
            return dxfDataClass;
        }

        public override void GetDevList(IniFile inifile, int index)
        {
            for (int i = index*4+1; i < index*4+4+1; i++)
            {
                DevClass devClass = new DevClass();
                string strs = inifile.GetString("直流道岔", (i + 1).ToString(), "");
                string[] s = strs.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                int n = s.Length;
                devClass.DevName = s[0];
                if (n <= 1)
                {
                    devClass.peiList.Add(" ");
                    devClass.peiList.Add(" ");
                    devClass.peiList.Add(" ");
                    devClass.peiList.Add(" ");
                }
                else
                {
                    devClass.peiList.Add(s[1] + "-1");
                    devClass.peiList.Add(s[1] + "-3");
                    devClass.peiList.Add(s[1] + "-2");
                    devClass.peiList.Add(s[1] + "-3");
                }
                DevList.Add(devClass);
            }
        }
    }
}
